<cfcomponent>
	
	<cfset variables.commands = structNew() />

	<cffunction name="init" access="public" returntype="KalendarService" output="false">
		<cfargument name="CommandConfig" type="any" required="true"/>

		<cfset structAppend( variables.commands, arguments.CommandConfig.getConfig() ) />

		<cfreturn this />
	</cffunction>

	<!--- 	Date: 10/27/2007  Usage: I load the specified command --->
	<cffunction name="loadCommand" output="false" access="public" returntype="any" hint="I load the specified command">
		<cfargument name="command" type="string" default="NullCommand" />
		<!--- Start off with a reference to the null command --->
		<cfset var rtnCommand = variables.commands.NullCommand />
		<!--- See if a particular command was needed and if so, get it --->
		<cfif structKeyExists( variables.commands, arguments.command ) >
			<cfset rtnCommand = variables.commands[ arguments.command ] />
		</cfif>
		<!--- <cfdump var="#rtnCommand#"><cfabort showError="Test" /> --->
		<cfreturn rtnCommand />
	</cffunction>
	
	<cffunction name="loadEvent" output="false" access="public" returntype="any" hint="I load the passed Kalendar Event object">
		<cfargument name="KalendarEvent" type="any" required="true"/>
		<cfset getKalendarDAO().read( arguments.KalendarEvent ) />
		<cfreturn arguments.KalendarEvent />
	</cffunction>	
		
	<cffunction name="loadInput" output="false" access="public" returntype="struct" hint="I append all the input structs">
		<cfargument name="URL" type="struct" required="true" />
		<cfargument name="Form" type="struct" required="true" />
		<cfargument name="Default" type="struct" default="#StructNew()#" />
		<cfargument name="Precedence" type="string" default="form" />
		<cfset var returnStruct = arguments.default />
		<!--- Blend in the URL struct --->
		<cfset structAppend( returnStruct, arguments.URL ) />
		<!--- Blend in the form scope --->
		<cfset structAppend( returnStruct, arguments.Form ) />
		<!--- If the user prefers URL variable precedence, blend it again --->
		<cfif arguments.Precedence IS "url">
			<cfset structAppend( returnStruct, arguments.URL ) />
		</cfif>	
		<!--- Give the nice people what they asked for --->
		<cfreturn returnStruct />
	</cffunction>
	
	<cffunction name="loadCategory" output="false" access="public" returntype="any" hint="I load a category bean object from the persistance layer">
		<cfargument name="CategoryBean" type="any" required="true"/>
		<cfset getCategoryDAO().read( arguments.CategoryBean ) />
		<cfreturn arguments.CategoryBean >		
	</cffunction>

	<cffunction name="formatShortDate" output="false" access="public" returntype="any" hint="I return a date formatted according to the configured short date mask">
		<cfargument name="preformatDate" type="date" required="true"/>		
		<!--- Format the passed date with the short date mask in the config --->
		<cfreturn dateFormat( arguments.preformatDate, getKalendarConfig().getShortDateMask ) />
	</cffunction>

	<cffunction name="formatShortTime" output="false" access="public" returntype="any" hint="I return a date formatted according to the configured short time mask">
		<cfargument name="preformatTime" type="date" required="true"/>		
		<!--- Format the passed date with the short date mask in the config --->
		<cfreturn timeFormat( arguments.preformatTime, getKalendarConfig().getShortTimeMask ) />
	</cffunction>

	<cffunction name="getKalendarConfig" access="public" output="false" returntype="any">
		<cfreturn variables.instance.KalendarConfig />
	</cffunction>
	
	<cffunction name="setKalendarConfig" access="public" output="false" returntype="void">
		<cfargument name="KalendarConfig" type="any" required="true" />
		<cfset variables.instance.KalendarConfig = arguments.KalendarConfig />
	</cffunction>
	
	<cffunction name="getKalendarDAO" access="public" output="false" returntype="any">
		<cfreturn variables.instance.KalendarDAO />
	</cffunction>
	
	<cffunction name="setKalendarDAO" access="public" output="false" returntype="void">
		<cfargument name="KalendarDAO" type="any" required="true" />
		<cfset variables.instance.KalendarDAO = arguments.KalendarDAO />
	</cffunction>

	<cffunction name="getCategoryDAO" access="public" output="false" returntype="any">
		<cfreturn variables.instance.CategoryDAO />
	</cffunction>
	
	<cffunction name="setCategoryDAO" access="public" output="false" returntype="void">
		<cfargument name="CategoryDAO" type="any" required="true" />
		<cfset variables.instance.CategoryDAO = arguments.CategoryDAO />
	</cffunction>
	
</cfcomponent>